Skip to content

Add CLAUDE.md with guidance for AI coding assistants#29171

Merged
raunaqmorarka merged 1 commit intotrinodb:masterfrom
raunaqmorarka:raunaq/claude-md
Apr 21, 2026
Merged

Add CLAUDE.md with guidance for AI coding assistants#29171
raunaqmorarka merged 1 commit intotrinodb:masterfrom
raunaqmorarka:raunaq/claude-md

Conversation

@raunaqmorarka
Copy link
Copy Markdown
Member

Summary

  • Adds a top-level CLAUDE.md documenting Trino-specific conventions for AI coding assistants (Claude Code and similar tools that auto-load CLAUDE.md as project context).
  • Covers code style do's and don'ts, Airlift import ordering and brace placement, configuration property naming and lifecycle (@ConfigDescription, @LegacyConfig, @DefunctConfig), and Maven build rules.
  • Points to .github/DEVELOPMENT.md for topics already documented there (Web UI build, release process, Vector API, IDE setup rationale) rather than duplicating them.

Test plan

  • File renders correctly on GitHub

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0c3a8efdb8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread CLAUDE.md Outdated
@raunaqmorarka
Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 20, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a repository-level CLAUDE.md intended to be auto-loaded by AI coding assistants, documenting Trino-specific conventions and pointing to existing development documentation where appropriate.

Changes:

  • Introduces CLAUDE.md with guidance on code style, formatting/import conventions, configuration/session property conventions, and Maven build workflows.
  • Cross-references .github/DEVELOPMENT.md for topics already covered elsewhere.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread CLAUDE.md Outdated
Comment thread CLAUDE.md Outdated
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 20, 2026

📝 Walkthrough

Walkthrough

A new contributor documentation file CLAUDE.md is added to the repository root. It provides contributor guidance for the Trino project, covering code style conventions, Java formatting and tooling expectations, configuration and session property naming conventions, and Maven build and test workflows. The document references .github/DEVELOPMENT.md for additional development topics.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
CLAUDE.md (1)

17-17: Consider clarifying the format() reference.

The guidance mentions format() with "(statically imported)" but doesn't specify the source. Consider adding the fully qualified name (e.g., String.format() or io.trino.spi.TrinoException.format()) for first-time contributors who might be unsure what to import.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@CLAUDE.md` at line 17, Clarify which format() is meant by updating the
guidance to name the exact API used—e.g., replace the ambiguous "format()
(statically imported)" with a fully qualified reference such as String.format()
when referring to Java's standard method or io.trino.spi.TrinoException.format()
if referring to the Trino helper, and mention that it should be statically
imported only when the Trino-specific helper is intended; ensure the text
briefly states which import to use so first-time contributors know which symbol
to import.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@CLAUDE.md`:
- Line 17: Clarify which format() is meant by updating the guidance to name the
exact API used—e.g., replace the ambiguous "format() (statically imported)" with
a fully qualified reference such as String.format() when referring to Java's
standard method or io.trino.spi.TrinoException.format() if referring to the
Trino helper, and mention that it should be statically imported only when the
Trino-specific helper is intended; ensure the text briefly states which import
to use so first-time contributors know which symbol to import.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 7e7cfd5a-a436-401b-a4b9-898c66b5ad32

📥 Commits

Reviewing files that changed from the base of the PR and between b935b2b and 0c3a8ef.

📒 Files selected for processing (1)
  • CLAUDE.md

Comment thread CLAUDE.md Outdated
Comment thread CLAUDE.md Outdated
Comment thread CLAUDE.md Outdated
Comment thread CLAUDE.md Outdated
Comment thread CLAUDE.md Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread CLAUDE.md Outdated
Comment thread CLAUDE.md Outdated
@raunaqmorarka raunaqmorarka force-pushed the raunaq/claude-md branch 2 times, most recently from eebd332 to 269785e Compare April 20, 2026 18:20
Comment thread CLAUDE.md Outdated
Comment thread CLAUDE.md Outdated
Comment thread CLAUDE.md Outdated
@findepi findepi requested a review from hashhar April 20, 2026 18:30
Comment thread CLAUDE.md Outdated

Run `mcp__idea__reformat_file` after every Java edit — it applies the Airlift scheme imported into IntelliJ. Rules not covered by the formatter:

- No wildcard imports (e.g. `import io.trino.spi.*`) — checkstyle catches these on build; easier to avoid writing them.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't that covered by airlift formatter?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested this with mcp__idea__reformat_file on a file with import java.util.*; — the wildcard wasn't expanded. The MCP tool invokes "Reformat Code" only (no Optimize Imports, no Cleanup), so it doesn't pick up the Airlift scheme's wildcard-expansion behavior. Checkstyle still catches them at build time, but for Claude's first-draft output it helps to have the rule here. Keeping the bullet.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The MCP tool invokes "Reformat Code" only (no Optimize Imports, no Cleanup), so it doesn't pick up the Airlift scheme's wildcard-expansion behavior.

We should teach Claude to optimize imports via intellij too then.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude can only make intellij do whatever intellij MCP exposes

Comment thread CLAUDE.md Outdated
Run `mcp__idea__reformat_file` after every Java edit — it applies the Airlift scheme imported into IntelliJ. Rules not covered by the formatter:

- No wildcard imports (e.g. `import io.trino.spi.*`) — checkstyle catches these on build; easier to avoid writing them.
- Braces required around single-statement `if` / `for` / `while` bodies — the formatter does not add missing braces.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my intellij somehow adds braces for if during reformat.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also tested — created a file with if (x > 0) System.out.println("hi");, ran mcp__idea__reformat_file, and the braces were not added. Same reason as the wildcard case: the MCP tool runs plain Reformat Code, not Reformat and Cleanup. Your IDE likely has "Reformat and Cleanup" bound or code cleanup enabled in the reformat dialog, but that doesn't carry over when Claude invokes the formatter through the MCP. Keeping the bullet.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then there are likely other things we would need to write here, if we cannot have Claude use Intellij's full reformatting power.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I imagine Intellij MCP will get better over time, meanwhile it is fine to add more rules here if we need to.
Claude is pretty good about taking cues from existing code though, so we don't need to be exhaustive

Comment thread CLAUDE.md Outdated
Comment thread CLAUDE.md Outdated
@findepi
Copy link
Copy Markdown
Member

findepi commented Apr 20, 2026

@hashhar PTAL

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread CLAUDE.md Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread CLAUDE.md Outdated
Comment thread CLAUDE.md
Comment thread CLAUDE.md Outdated
Copy link
Copy Markdown
Member

@hashhar hashhar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good start. Very closely matches what I have as well. I do have to often tell it to rebuild (using clean + -am or -amd) instead of manually trying to -pl it's way to a successful build. Sadly haven't managed to find the words to get it to stop doing that.

Comment thread CLAUDE.md Outdated
Comment thread CLAUDE.md Outdated
Comment thread CLAUDE.md Outdated
Comment thread CLAUDE.md Outdated
Comment thread CLAUDE.md Outdated
@hashhar
Copy link
Copy Markdown
Member

hashhar commented Apr 20, 2026

For testing I have unit test knowledge described in claude.md:

  • -Dair.test.thread-count as a possible useful thing
  • Prefer improving/expanding existing tests over creating new ones. Consolidate related scenarios.
  • Prefer clarity over defensive programming in tests. Use direct assertions without defensive checks. Only sanitize what's actually unsafe.

For product tests (click to see full content):

Details
# Product Tests

## Running
```bash
# List available suites and environments
./bin/ptl suite list
./bin/ptl env list

# Run a product test suite
./bin/ptl suite run --suite <suite-name>

# Run a product test group
./bin/ptl test run --environment <env-name> -- -g <group-name1>,<group-name2>

# Run a specific test
./bin/ptl test run --environment <env-name> -- -t <fully-qualified-method-name1>,<fully-qualified-method-name2>

Building

After changing product test code, rebuild both modules before running:

mvnd install -pl :trino-product-tests,:trino-product-tests-launcher -DskipTests -Dair.check.skip-all=true

The launcher copies the test jar and server-main into Docker containers, so they must be rebuilt too if required.

Infrastructure

  • Tests run inside a tests Docker container on the ptl-network
  • Trino coordinator container: presto-master (port 8080)
  • Container names defined in EnvironmentContainers.java
  • Environment providers live in trino-product-tests-launcher under env/environment/
  • Suite definitions live in trino-product-tests-launcher under suite/suites/
  • Test groups defined in trino-product-tests-groups/.../TestGroups.java
  • Tempto configuration (JDBC connections, users) in trino-product-tests-launcher/src/main/resources/docker/trino-product-tests/

Framework

  • Tests use Tempto (TestNG-based, NOT JUnit). See also Trino product tests README
  • Tests extend io.trino.tempto.ProductTest and use @Test(groups = {...}) for grouping
  • Queries run via JDBC through QueryExecutor (e.g. connectToTrino(), onPostgres())
  • Dependency injection via Guice (@Inject, @Named("databases.trino.server_address"))
  • Multiple user configs (alice, bob, etc.) defined per environment in tempto-configuration.yaml

Test setup: @BeforeMethodWithContext

  • DO NOT use @BeforeClass or @BeforeMethod - Tempto Guice injection hasn't happened yet at that point
  • Use @BeforeMethodWithContext (from io.trino.tempto) - runs after injection, before each test method
  • For one-time setup, guard with private volatile boolean initialized (standard Trino pattern):
    private volatile boolean initialized;
    
    @BeforeMethodWithContext
    public void setUp()
    {
        if (initialized) {
            return;
        }
        // ... one-time setup
        initialized = true;
    }

Test groups and PROFILE_SPECIFIC_TESTS

  • PROFILE_SPECIFIC_TESTS marks tests that require a specific environment/profile to run
  • The default test runner excludes profile_specific_tests - tests in this group are skipped unless explicitly included
  • Custom suites that provide the right environment should NOT use PROFILE_SPECIFIC_TESTS - the suite already guarantees the correct environment via its EnvironmentProvider
  • Use PROFILE_SPECIFIC_TESTS only when the test also belongs to a broader group that runs across multiple environments (e.g. INSIGHTS tests that run in both generic and specific profiles)

Environment providers

  • Live in trino-product-tests-launcher under env/environment/, annotated with @TestsEnvironment
  • Extend EnvironmentProvider, compose base modules (e.g. StandardMultinode, Hadoop, Minio) via constructor injection
  • Override extendEnvironment(Environment.Builder) to configure containers, copy files, set env vars
  • Config files per environment: conf/environment/<env-name>/config-coordinator.properties etc., copied into containers via withCopyFileToContainer()

Suite definitions

  • Live in trino-product-tests-launcher under suite/suites/, extend Suite
  • Override getTestRuns(EnvironmentConfig) returning List<SuiteTestRun>
  • Each SuiteTestRun pairs an environment with test groups: .withGroups(...), .withExcludedGroups(...), .withTests(...), .withExcludedTests(...)

Debugging

  • View coordinator logs: docker logs presto-master
  • View test container logs: docker logs tests
  • Worker logs: docker logs presto-worker-1 (etc.)
  • Filter tests with -t <fully.qualified.MethodName> or -g <group-name> to iterate quickly on failures
</details>
</summary>

Top-level CLAUDE.md points at the authoritative code-style sources
(.github/DEVELOPMENT.md, modernizer, checkstyle), documents the
JetBrains MCP server usage, and lists the minimal Java formatting rules
the IntelliJ reformatter does not auto-fix. Config-property conventions
live as a path-scoped rule under .claude/rules/ so they activate
automatically when Claude reads matching *Config.java files.

.gitignore narrowed from the whole .claude/ directory to just
settings.local.json and worktrees/, so project-level rules and future
.claude/ content can be committed while per-user files stay ignored.
@raunaqmorarka
Copy link
Copy Markdown
Member Author

Thanks for sharing. The testing content fits the .claude/rules/ pattern we're establishing here — unit-test bullets in .claude/rules/unit-tests.md (path-scoped to **/src/test/**/*.java), product-test guidance in .claude/rules/product-tests.md (scoped to **/trino-product-tests*/**). Keeping that out of this PR to avoid scope creep, but happy to open a follow-up that pulls your content across, or defer to you if you'd rather own it directly.

@raunaqmorarka raunaqmorarka merged commit 8f35d38 into trinodb:master Apr 21, 2026
38 of 98 checks passed
@raunaqmorarka raunaqmorarka deleted the raunaq/claude-md branch April 21, 2026 06:16
@github-actions github-actions Bot added this to the 481 milestone Apr 21, 2026
@ebyhr ebyhr mentioned this pull request Apr 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

6 participants